﻿using UnityEngine;
using System.Collections;

public class FSMStateDemo : MonoBehaviour {
	FSM fsm;
	State state;
	StateMachine sm;
	StatePath sp;
	StatePath home;
	// Use this for initialization
	void Start () {
		fsm = new FSM ();
		home = new StatePath ("Home/");
		sp = new StatePath ("Home/Role");

//		fsm.AddState (sp,delegate() {
//			Debug.Log("sp enter");
//		});
//		fsm.AddStateMachine (home, delegate() {
//			Debug.Log("sp sm enter");	
//		});
		sm = fsm.AddStateMachine<Home> (this);
		state = fsm.AddState<Role> (this,sm);

	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown("1"))
			fsm.SetState (state);
		if(Input.GetKeyDown("2"))
			fsm.SetState (sp);
	}
	void OnGUI(){
		fsm.stateMachine.OnGUI ();
	}
}
public class FSMUIState:FSMStateBase{
	public override void SetActor (object actor)
	{
	}
	public virtual void DrawGUI(){
		
	}
}
public class FSMUIStateMachine:FSMStateMachineBase{
	public override void SetActor (object actor)
	{
	}
	public virtual void DrawGUI(){

	}
}
public class Role:FSMUIState{
	public override void OnEnter ()
	{
		base.OnEnter ();
		Debug.Log ("State1 Enter");
	}
}


public class Home:FSMUIStateMachine
{
	public override void OnEnter ()
	{
		base.OnEnter ();
		Debug.Log (" sm enter");
	}
}